﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace ZhiHeng.OneCard.WpfClient
{
    public class ZQ_8DL
    {
        [DllImport("Zonerich_com.dll", EntryPoint = "com_init", SetLastError = true,
             CharSet = CharSet.Auto, ExactSpelling = false,
             CallingConvention = CallingConvention.StdCall)]
        public static extern int com_init(int port, int baud);

        [DllImport("Zonerich_com.dll", EntryPoint = "pos_init", SetLastError = true,
             CharSet = CharSet.Auto, ExactSpelling = false,
             CallingConvention = CallingConvention.StdCall)]
        public static extern void pos_init();

        [DllImport("Zonerich_com.dll", EntryPoint = "clr", SetLastError = true,
             CharSet = CharSet.Auto, ExactSpelling = false,
             CallingConvention = CallingConvention.StdCall)]
        public static extern void clr();

        [DllImport("Zonerich_com.dll", EntryPoint = "StopComm", SetLastError = true,
             CharSet = CharSet.Auto, ExactSpelling = false,
             CallingConvention = CallingConvention.StdCall)]
        public static extern void StopComm(int port, int baud);

        [DllImport("Zonerich_com.dll", EntryPoint = "com_vbsend", SetLastError = true,
                CharSet = CharSet.Auto, ExactSpelling = false,
                CallingConvention = CallingConvention.StdCall)]
        public static extern void com_vbsend(byte[] buffer, int bufSize);
        public static void com_send(string buffer)
        {
            com_vbsend(System.Text.ASCIIEncoding.ASCII.GetBytes(buffer), buffer.Length);
        }

        [DllImport("Zonerich_com.dll", EntryPoint = "setshowcmd", SetLastError = true,
                CharSet = CharSet.Auto, ExactSpelling = false,
                CallingConvention = CallingConvention.StdCall)]
        public static extern void setshowcmd(enCmdType n);

        public enum enCmdType : int
        {
            全暗 = 48,
            单价 = 49,
            应收 = 50,
            实收 = 51,
            找回 = 52
        }

    }


}


